package test;

import java.security.PublicKey;
import java.util.Scanner;

/**
 * @author 郝雷蒙
 * @Description
 * @date 2020/12/1 11:05
 */
public class AAA {
    public static void main(String[] args) {

    AAA.b();
    AAA.a();
    AAA.sort();
    }

    public static void b(){
        String content = "ABC137GMNQQ2049PN5FFF";
        String word = "";

        for (int i = 0; i < content.length(); i++) {
            char c = content.charAt(i);

            if (c>='0' && c <='9'){
                word +=c;
            }

        }
      int[] a = new int[word.length()];
        for (int i = 0; i < word.length(); i++) {
            a[i] = Integer.parseInt(word.substring(i,i+1));
        }
        for (int i = 0; i < a.length; i++) {
            for (int j = i+1; j < a.length ; j++) {
                if (a[i] >a[j]){
                    int h = 0;
                    h= a[i];
                    a[i] = a[j];
                    a[j] = h;
                }
            }
        }
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i]);
        }

       
    }



    public static void sort(){
        Scanner sc = new Scanner(System.in);
        int array[] = { 23,12,47,89,36,27,38,75,48,64 };

        for (int i = 0; i < 10; i++) {
            for (int j=i+1; j < 10; j++) {
                if (array[i] > array[j]){
                    int a=0 ;
                    a = array[i];
                    array[i] = array[j];
                    array[j] = a;

                }
            }
        }
        for (int i = 0; i < 10; i++) {
            System.out.print(array[i]);
            System.out.println();
        }

        System.out.println("请输入你要查找的数");
        int B = sc.nextInt();
        int min =0;                //最小下标
        int max = array.length-1;  //最大下标
        int mid = 0;                //中间下标


        while (min <max){
            mid =(min+max)/2;
            if (array[mid]>B){   //B在mid的左边
                max = mid-1;     //改变最大下标
            }else if (array[mid]<B){    //B在mid的右边
                min = mid+1;            //改变最小下标
            }else {
                System.out.println(mid);
                break;
            }
        }
    }

    public static void a(){
        String content = "Hello!  Game programming  world!";
        String word = "";
        boolean isAlpha = false;

        for (int i = 0; i < content.length(); i++) {
            char c = content.charAt(i);

            //大小写字母
            if ((c>= 'A' && c<= 'Z') || (c>= 'a' && c<= 'z') ||(c >= '0' && c <= '9')){
                word += c;
                if (!isAlpha){
                    word = ""+ c;

                    isAlpha = true;

                }
            }else if (c == '!' || c =='\''){
                word += c;
                if (!isAlpha){
                    word = "" + c;
                    isAlpha = true;
                }
            }
            else {
                if (isAlpha) {
                    System.out.print(word+" ");

                    isAlpha = false;
                }
            }

        }
        System.out.print(word);
    }



}

